package fr.alesia.capital.bean.comparator;

import java.util.Comparator;

import fr.alesia.capital.bean.Pays;

public class ContinentComparator implements Comparator<Pays> {
	
	private static Comparator<Pays> instance = null;
	
	private ContinentComparator(){}
	
	public static Comparator<Pays> getComparator(){
		if(instance == null){
			instance = new ContinentComparator();
		}
		return instance;
	}

	public int compare(Pays one, Pays two) {
		
		if(one.getContinent() == two.getContinent()){
			return PaysComparator.getComparator().compare(one, two);
		}
		else{
			return one.getContinent().compareTo(two.getContinent());
		}
	}
}
